/**
 * Created by IntelliJ IDEA.
 * User: martlenn
 * Date: 24-Jan-2008
 * Time: 16:24:11
 */
package org.hkupp.db.accessors;

import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import java.util.HashMap;
/*
 * CVS information:
 *
 * $Revision$
 * $Date$
 */

/**
 * This class extends the ModificationTable Accessor.
 *
 * @author Lennart Martens
 * @version $Id$
 */
public class Modification extends ModificationTableAccessor {

    public Modification(HashMap aData) {
        super(aData);
    }

    public Modification(ResultSet aRs) throws SQLException {
        super(aRs);
    }

    /**
     * Returns the Modification object for the specified name,
     * or 'null' if none was found.
     *
     * @param aConn Connection to retrieve the Modification from.
     * @param aName String with the name of the modification to look up.
     * @return  Modification with the specified name, or 'null' if none was found.
     * @throws  SQLException when the database could not be contacted.
     */
    public static Modification findModification(Connection aConn, String aName) throws SQLException {
        Modification result = null;
        Statement stat = aConn.createStatement();
        ResultSet rs = stat.executeQuery("select * from modification where name = '" + aName + "'");
        while(rs.next()) {
            result = new Modification(rs);
        }
        return result;
    }
}
